package lesson02;

public class Test03 {
    public static void main(String[] args) {
        // 二维数组
//        int [][] ary = new int[5][5];
        // 5X5的矩阵
        int [][] ary = {
                {1,  2, 3, 4, 5},
                {6,  7, 8, 9,10},
                {11,12,13,14,15},
                {16,17,18,19,20},
                {21,22,23,24,25},
        };
//        System.out.println(ary[0][1]);
//        int sum = 0;
//        for(int i = 0;i < ary.length;i++){
//            for(int j = 0;j < ary[i].length;j++){
//                if(i == j || i + j == 4){
//                   sum += ary[i][j];
//                }
//                System.out.print(ary[i][j]+",");
//            }
//            System.out.println();
//        }
//        System.out.println(sum);

        int [][] ary1 = {
                {1,2,3},
                {4,5,6},
                {7,8,9}
        };
        for(int i = 0;i < ary1.length;i++){
            for(int j = 0;j < ary1[i].length;j++){
                if(i < j){
                    int temp = ary1[i][j];
                    ary1[i][j] = ary1[j][i];
                    ary1[j][i] = temp;
                }
            }
        }
        for(int i = 0;i < ary1.length;i++){
            for(int j = 0;j < ary1[i].length;j++){
                System.out.print(ary1[i][j] + ",");

            }
            System.out.println();
        }

        // 字符串和字符数组的转换
        String str = "hello";
        char [] cs = str.toCharArray();
        System.out.println(cs.length + " " + cs[0]);

        // 字符数组转换为字符串
        String str1 = new String(cs);
        System.out.println(str1);

        System.out.println(Math.random());
        for (int i = 0;i < 100;i++){
            System.out.println("随机数：" + (int)(Math.random() * 6 + 5));
        }

    }
}
